function [OO_commit, RS_commit,...
    vartype_commit, values_commit] = cf_commitment( cost2_0, cost2_1_all, D_input, D, N,...
    D_enroll_st, ...
    alpha, ...
    Delta_xi_all, cost1_e_all, mu_f_all, sigma_f_all,...
    K, pr_y, N_y, resource_y1, resource_y2, y_medi, x_fc, pr_fc, ...
    rho, crra, sigma_c1, beta_c, beta_f, T1, T2, B1_c, B2_c, B1_f, B2_f, delta, ...
    lr_target, N_f, entry_exitflag_vec, id_ist_old, myopic, Er, cost_weight, use_cost_weight, root_dir)

disp(' ')
disp('====================================================')
disp('Commitment case (only one price for each contract)')

% initial guess on eqm outcomes
p1_ini = D_input.p1; % NN x 1
p2_ini = D_input.p2; % NN x KM
n_ini_unmerge = D_input.n_insurers; % NN x 1: 1 for majors, # fringes for the fringe
n_ini = zeros(N.st,1); % N_st x 1. bring down to market level
for mm=1:N.st
    n_ini(mm) = unique(n_ini_unmerge(D_input.mkt==mm & D_input.major==0));
end

% commitment equilibrium
[p1_cf, p2_cf, n_cf, ...
    profit_cf, non_converge_all_cf, solve_market_all_cf, fsolve_all_cf, ...
    EV_y_cf, EV_cf, enrollment_cf, enrollment_m_cf, enrollment_f_cf, enrollment_per_m_cf, enrollment_per_f_cf, non_converge_cf, solve_market_cf,...
    s1_mkt_cf, s2_mkt_cf, rs_share_cf]...
    = solve_eq_commit(alpha, ...
    Delta_xi_all, cost1_e_all, cost2_1_all,  mu_f_all, sigma_f_all,...
    cost2_0, D_input, N, ...
    K, pr_y, N_y, resource_y1, resource_y2, y_medi, x_fc, pr_fc, ...
    rho, crra, sigma_c1, beta_c, beta_f, T1, B1_c, B2_c, B1_f, B2_f, delta, ...
    lr_target, N_f, entry_exitflag_vec, id_ist_old, Er,...
    p1_ini, n_ini, cost_weight, use_cost_weight);

ss=1;
OO_commit(ss).p1_cf=p1_cf;
OO_commit(ss).p2_cf=p2_cf;
OO_commit(ss).n_cf=n_cf;
OO_commit(ss).profit_cf=profit_cf;
OO_commit(ss).non_converge_all_cf = non_converge_all_cf;
OO_commit(ss).solve_market_all_cf = solve_market_all_cf;
OO_commit(ss).fsolve_all_cf = fsolve_all_cf;
OO_commit(ss).EV_y_cf = EV_y_cf;
OO_commit(ss).EV_cf = EV_cf;
OO_commit(ss).enrollment_cf = enrollment_cf;
OO_commit(ss).enrollment_m_cf = enrollment_m_cf;
OO_commit(ss).enrollment_f_cf = enrollment_f_cf;
OO_commit(ss).enrollment_per_m_cf = enrollment_per_m_cf;
OO_commit(ss).enrollment_per_f_cf = enrollment_per_f_cf;
OO_commit(ss).non_converge_cf=non_converge_cf;
OO_commit(ss).solve_market_cf=solve_market_cf;
OO_commit(ss).s1_mkt_cf = s1_mkt_cf;
OO_commit(ss).s2_mkt_cf = s2_mkt_cf;
OO_commit(ss).rs_share_cf = rs_share_cf;

% baseline equilibrium 
[p1_cf, p2_cf, n_cf, ...
    profit_cf, non_converge_all_cf, solve_market_all_cf, fsolve_all_cf, ...
    EV_y_cf, EV_cf, enrollment_cf, enrollment_m_cf, enrollment_f_cf, enrollment_per_m_cf, enrollment_per_f_cf, non_converge_cf, solve_market_cf,...
    s1_mkt_cf, s2_mkt_cf, rs_share_cf]...
    = solve_eq(alpha, ...
    Delta_xi_all, cost1_e_all, cost2_1_all,  mu_f_all, sigma_f_all,...
    cost2_0, D_input, N, ...
    K, pr_y, N_y, resource_y1, resource_y2, y_medi, x_fc, pr_fc, ...
    rho, crra, sigma_c1, beta_c, beta_f, T1, B1_c, B2_c, B1_f, B2_f, delta, ...
    lr_target, N_f, entry_exitflag_vec, id_ist_old, myopic, Er,...
    p1_ini, p2_ini, n_ini, cost_weight, use_cost_weight);

ss=2;
OO_commit(ss).p1_cf=p1_cf;
OO_commit(ss).p2_cf=p2_cf;
OO_commit(ss).n_cf=n_cf;
OO_commit(ss).profit_cf=profit_cf;
OO_commit(ss).non_converge_all_cf = non_converge_all_cf;
OO_commit(ss).solve_market_all_cf = solve_market_all_cf;
OO_commit(ss).fsolve_all_cf = fsolve_all_cf;
OO_commit(ss).EV_y_cf = EV_y_cf;
OO_commit(ss).EV_cf = EV_cf;
OO_commit(ss).enrollment_cf = enrollment_cf;
OO_commit(ss).enrollment_m_cf = enrollment_m_cf;
OO_commit(ss).enrollment_f_cf = enrollment_f_cf;
OO_commit(ss).enrollment_per_m_cf = enrollment_per_m_cf;
OO_commit(ss).enrollment_per_f_cf = enrollment_per_f_cf;
OO_commit(ss).non_converge_cf=non_converge_cf;
OO_commit(ss).solve_market_cf=solve_market_cf;
OO_commit(ss).s1_mkt_cf = s1_mkt_cf;
OO_commit(ss).s2_mkt_cf = s2_mkt_cf;
OO_commit(ss).rs_share_cf = rs_share_cf;

% save
save('cf_commit.mat')


